let mySet = new Set();
mySet.add(1);
mySet.add(5);
mySet.add("some text");

let o = {a:1,b:2}
mySet.add(o);

const has = mySet.has(1);
mySet.delete(5);


//迭代set
for (let item of mySet) console.log(item);
for (let item1 of mySet.keys()) console.log(item1);
for (let item2 of mySet.values()) console.log(item2);
for (let [key,value] of mySet.entries()) console.log(key,value);

//set与array转换
const myArr = [...mySet];
const myArr1 = Array.from(mySet);
const mySet1 = new Set(myArr);

//求交集、差集
const intersection = new Set([...mySet].filter(n => mySet1.has(n)));
const difference = new Set([...mySet].filter(n => !mySet1.has(n)));